package Java多线程和并发.ScheduledThreadPoolExecutor详解;

import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.TimeUnit;

/**
 * @program: algorithm
 * @description: 错误的Timer行为
 * @author: 陈恩涛
 * @create: 2022-04-02 16:39
 **/
public class OutOfTime {

    static class ThrowTask extends TimerTask {
        @Override
        public void run() {
            throw new RuntimeException();
        }
    }

    public static void main(String[] args) throws Exception{
        Timer timer = new Timer();
        timer.schedule(new ThrowTask(), 1);
        TimeUnit.SECONDS.sleep(1);
        timer.schedule(new ThrowTask(), 1);
        TimeUnit.SECONDS.sleep(5);
    }
}
